package dowm1;

public class CreditCard extends BankCard {
    // 透支额度属性
    private double creditLimit;

    public double getCreditLimit() {
        return creditLimit;
    }

    public void setCreditLimit(double creditLimit) {
        this.creditLimit = creditLimit;
    }

    public CreditCard(double balance) {
        super(balance);
        this.creditLimit = creditLimit;
    }

    // 重写取款方法
    @Override
    public boolean withdraw(double amount) {
        if (amount > 0 && amount <= (super.getBalance() + creditLimit)) {
            // 可以透支，所以余额可以是负数
            super.withdraw(amount); // 调用父类的取款方法
            return true;
        } else {
            System.out.println("透支额度不足或取款金额不合法");
            return false;
        }
    }
}
